## -*-m4-*-

dnl Process this file with autoconf to produce a configure script.

# FILE:
# configure.in
#
# FUNCTION:
# implements checks for a variety of system-specific functions
#
# Contents:
#   Headers   - Autoconf header stuff
#   Variables - Hardcoded variables
#   Programs  - Check for programs binaries
#   Functions - Check for functions
#   With      - Check for --with/without options
#   Enable    - Check for --enable/disable options
#   Libraries - Check for libraries
#   Footer    - Autoconf footer stuff

# Autoconf initialization
AC_PREREQ(2.60)
AC_INIT([GnuCash], [2.7.2], [https://bugzilla.gnome.org/page.cgi?id=browse.html&product=GnuCash], , [http://www.gnucash.org/])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_SRCDIR(libgnucash/engine/Transaction.h)
AC_CONFIG_MACRO_DIR([macros])

#Change this in development versions when changing anything that
#affects stored data structures. Reset to zero when bumping version.
GNUCASH_NANO_VERSION=0
#This should be the earliest version in the form XXMMUUNN (XX=MAJOR,
#MM=MINOR, UU=MICRO, NN=NANO) or SVN revision if before 2.4.1 which is
#storage-compatible with the current version. See the comments in
#libgnucash/backend/dbi/gnc-backend-dbi.c:gnc_dbi_load.
GNUCASH_RESAVE_VERSION=19920
# Initialize automake -- make sure we have at least version 1.9 Note:
# Automake 1.14 & 1.15 issue a ton of warnings about subdir-objects, which
# will become the default in automake 2.0; unfortunately this option
# is broken and prevents building without passing
# --disable-dependency-tracking to configure, which make-distcheck
# doesn't do. Fixes are in git and expected in Automake-1.16. See
# http://lists.gnu.org/archive/html/automake/2014-04/msg00002.html and
# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928 for details.
# In the meantime the best option is to use Automake 1.13 or earlier.
AM_INIT_AUTOMAKE([1.9 tar-ustar dist-bzip2])

# Parse out the version number
GNUCASH_VERSION_STRING=AC_PACKAGE_VERSION
GNUCASH_MAJOR_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\1/' ]`
GNUCASH_MINOR_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\2/' ]`
GNUCASH_MICRO_VERSION=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\3/' ]`
GNUCASH_LATEST_STABLE_SERIES=$GNUCASH_MAJOR_VERSION.$(($GNUCASH_MINOR_VERSION-($GNUCASH_MINOR_VERSION%2)))

# save any user/environment optimization flags before we muck with them in
# --enable-debug:
USER_OPTIMIZATION=""
for flag in $CFLAGS; do
  tmp_flag=`echo $flag | sed -e 's,-O.,,'`
  if test -z "$tmp_flag"; then
    USER_OPTIMIZATION="$USER_OPTIMIZATION ${flag}"
  fi
done

##  Do this first, because the other tests depend on it:

# Check for gcc and intltool (somehow breaks the suggested content
# order, doesn't it? Whatever.)
AC_PROG_CC
AM_PROG_CC_C_O
AC_GNU_SOURCE
AC_PROG_INTLTOOL
# Ensure the C++ compiler supports C++ 11:
AX_CXX_COMPILE_STDCXX_11(ext)
# Ensure the C compiler supports C11
AX_CHECK_COMPILE_FLAG([-std=gnu11],
                      [AX_APPEND_FLAG([-std=gnu11])],
                      [AC_MSG_ERROR([The compiler doesn't support the C11 (gnu11) standard.])
                      ])

AC_SUBST(GNUCASH_MAJOR_VERSION)
AC_SUBST(GNUCASH_MINOR_VERSION)
AC_SUBST(GNUCASH_MICRO_VERSION)
AC_SUBST(GNUCASH_NANO_VERSION)
AC_SUBST(GNUCASH_LATEST_STABLE_SERIES)

AC_DEFINE_UNQUOTED(GNUCASH_MAJOR_VERSION, $GNUCASH_MAJOR_VERSION,
    [GnuCash Major version number])
AC_DEFINE_UNQUOTED(GNUCASH_MINOR_VERSION, $GNUCASH_MINOR_VERSION,
    [GnuCash Minor version number])
AC_DEFINE_UNQUOTED(GNUCASH_MICRO_VERSION, $GNUCASH_MICRO_VERSION,
    [GnuCash Micro version number])
AC_DEFINE_UNQUOTED(GNUCASH_NANO_VERSION, $GNUCASH_NANO_VERSION,
    [GnuCash Nano version number])
AC_DEFINE_UNQUOTED(GNUCASH_RESAVE_VERSION, $GNUCASH_RESAVE_VERSION,
    [GnuCash earliest compatible databaseversion number])
AC_DEFINE_UNQUOTED(GNUCASH_LATEST_STABLE_SERIES, "$GNUCASH_LATEST_STABLE_SERIES",
    [Most recent stable GnuCash series])

AC_ARG_VAR([GNUCASH_BUILD_ID],[Overrides the GnuCash build identification (Build ID) which defaults
to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package
management based version number instead])
AC_DEFINE_UNQUOTED(GNUCASH_BUILD_ID, "$GNUCASH_BUILD_ID",
                   [GnuCash build identification, which defaults
                   to a description of the vcs commit from which gnucash is built. Distributions may want
                   to insert a package management based version string instead.])

dnl Set of available languages:
dnl managed at the Translation Project:
TP_LINGUAS="az ca cs da eu fa ja nl rw sk sr sv tr uk zh_CN"
dnl already marked as external at TP:
GC_LINGUAS="ar bg de el en_GB es fi fr gu he hi hu it kn ko lt lv mr nb ne pl pt pt_BR ro ru ta te ur vi zh_TW "
dnl New or unmarked: The release manager should announce them to TP 
dnl and when listed there move in the respective group above.
NEW_LINGUAS="as brx doi es_NI kok kok@latin ks mai mni mni@bengali"

ALL_LINGUAS="$TP_LINGUAS $GC_LINGUAS $NEW_LINGUAS"

GETTEXT_PACKAGE=gnucash
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
    [GetText version number])

AM_GLIB_GNU_GETTEXT


# Enable only when we have autoconf --version >= 2.59
# on all platforms. Note that AC_PREREQ(2.59) may be
# insufficient to actually use v2.59 on OSX
#AC_CONFIG_MACRO_DIR(macros)

AC_PROG_INSTALL
PKG_PROG_PKG_CONFIG

dnl clang wants to check file encodings, and we need to tell it not to
dnl because of the unicode currency symbols. But older versions of GCC
dnl don't like the warning suppression option, so we need to set it only
dnl with clang.

AC_MSG_CHECKING([if compiling with clang])

AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
       not clang
#endif
]])],
[ac_cv_CLANG=yes], [ac_cv_CLANG=no])

AC_MSG_RESULT([$ac_cv_CLANG])
AM_CONDITIONAL([CLANG], [test "x$ac_cv_CLANG" = "xyes"])

###--------------------------------------------------------
### Begin C++ dependencies
###--------------------------------------------------------
PKG_CHECK_MODULES(ICU4C, icu-uc, [ac_cv_ICU4C=yes], [ac_cv_ICU4C=no])
PKG_CHECK_MODULES(ICU4C_I18N, icu-i18n, [ac_cv_ICU4C=yes], [ac_cv_ICU4C=no])
if test x$ac_cv_ICU4C != xyes; then
    AC_MSG_ERROR([ICU4C was not found and is required to build GnuCash.])
fi
AX_BOOST_BASE([1.53.0], [ac_cv_BOOST=yes], [ac_cv_BOOST=no])
if test x$ac_cv_BOOST != xyes; then
    AC_MSG_ERROR([Boost 1.53.0 or later was not found and is required to build GnuCash])
fi

# This section must come before AC_PROG_LIBTOOL because libtool
# must know about the c++ compiler.
###--------------------------------------------------------


AC_LIBTOOL_DLOPEN
AC_LIBTOOL_WIN32_DLL
AM_DISABLE_STATIC
AM_PROG_LIBTOOL

AC_SUBST(LIBTOOL_DEPS)

AC_ISC_POSIX
AC_C_BIGENDIAN
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_HEADER_STDC

AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h sys/wait.h pow.h)
oldcflags="$CFLAGS"
CFLAGS=
AC_LANG_PUSH([C++])
oldcxxflags="$CXXFLAGS"
CXXFLAGS="-Werror -std=gnu++11 $BOOST_CPPFLAGS"
AC_MSG_CHECKING([boost/date_time/local_time/custom_time_zone.hpp])
AC_COMPILE_IFELSE([
    AC_LANG_SOURCE([
#include <boost/date_time/local_time/local_time.hpp>

using duration = boost::posix_time::time_duration;
using time_zone = boost::local_time::custom_time_zone;
using dst_offsets = boost::local_time::dst_adjustment_offsets;
using TZ_Ptr = boost::local_time::time_zone_ptr;
using time_zone_names = boost::local_time::time_zone_names;

struct TTInfo
{
int32_t gmtoff;
uint8_t isdst;
uint8_t abbrind;
};

struct TZInfo
{
TTInfo info;
std::string name;
bool isstd;
bool isgmt;
};

static TZ_Ptr
zone_no_dst(int year, TZInfo *std_info)
{
    time_zone_names names(std_info->name, std_info->name, "", "");
    duration std_off(0, 0, std_info->info.gmtoff);
    dst_offsets offsets({0, 0, 0}, {0, 0, 0}, {0, 0, 0});
    boost::local_time::dst_calc_rule_ptr calc_rule(nullptr);
    TZ_Ptr tz(new time_zone(names, std_off, offsets, calc_rule));
    return tz;
}

	 ])],
	 [AC_MSG_RESULT([yes])],
	 [AC_MSG_FAILURE([
Boost Header Fails to compile with C++11. To fix this, open
date_time/local_time/custom_time_zone.hpp, perhaps as root,
in your boost include directory (/usr/include/boost in most cases)
and change line 67 to
      return (bool) dst_calc_rules_; //if calc_rule is set the tz has dst
])])
CXXFLAGS="$oldcxxflags"
AC_LANG_POP([C++])
oldldflags="$LDFLAGS"
LDFLAGS=
AC_CHECK_FUNCS(stpcpy memcpy timegm towupper)
AC_CHECK_FUNCS(setenv,,[
  AC_CHECK_FUNCS(putenv,,[
    AC_MSG_ERROR([Must have one of the setenv or putenv functions.])
  ])
])
CFLAGS="$oldcflags"
LDFLAGS="$oldldflags"
STRUCT_TM_GMTOFF_CHECK
cflags_save=${CFLAGS}
CFLAGS="${CFLAGS} -Wall -Werror"
SCANF_LLD_CHECK
if test x$am_cv_scanf_lld = "xno"; then
  SCANF_QD_CHECK

  if test x$am_cv_scanf_qd = "xno"; then
    SCANF_I64D_CHECK
    if test x$am_cv_scanf_i64d = "xno"; then
      AC_MSG_ERROR([Cannot continue, no long long conversion support in scanf.])
    fi
  fi
fi
CFLAGS="${cflags_save}"

# test whether we are building directly from svn/svk/git/bzr
AC_MSG_CHECKING(if building from an scm managed directory)
"$srcdir/util/gnc-vcs-info" -r "$srcdir" >/dev/null 2>&1
if test $? = 0 -o "x${BUILDING_FROM_VCS}" = "xyes" ; then
  BUILDING_FROM_VCS=yes
  VCS_TYPE=$("$srcdir/util/gnc-vcs-info" -t "$srcdir")
  AC_MSG_RESULT($VCS_TYPE)

  if test "x${VCS_TYPE}" = "xgit"; then
    AC_MSG_CHECKING(git command to use due to detected git repo)
    # The windows build uses environment variable $GIT_CMD to invoke git (adding git
    # to the PATH in Windows results in a build failure).
    # So for platform independence, use GIT_CMD for all
    if test -z "${GIT_CMD}" ; then
      GIT_CMD=git
    fi
    AC_MSG_RESULT(${GIT_CMD})
  fi
else
  AC_MSG_RESULT(no)
  BUILDING_FROM_VCS=no
  VCS_TYPE=

  # Make sure we've got swig-runtime.h and gnc-vcs-info.h
  AC_CHECK_FILE(${srcdir}/common/swig-runtime.h, [],
    [AC_MSG_ERROR([

It looks like you are NOT building from Subversion, svk, git or bzr
but I cannot find swig-runtime.h.  Check your PATH and make sure
we can find gnc-vcs-info in your PATH!
Either that or contact gnucash-devel@gnucash.org because
the tarball you downloaded is broken.

    ])])
  AC_CHECK_FILE(${srcdir}/libgnucash/core-utils/gnc-vcs-info.h, [],
    [AC_MSG_ERROR([

It looks like you are NOT building from Subversion, svk, git or bzr
but I cannot find gnc-vcs-info.h.  Check your PATH and make sure
we can find gnc-vcs-info in your PATH!
Either that or contact gnucash-devel@gnucash.org because
the tarball you downloaded is broken.

    ])])
fi
AM_CONDITIONAL(BUILDING_FROM_VCS, test "x$BUILDING_FROM_VCS" = "xyes")
AC_SUBST(VCS_TYPE)
AC_SUBST(GIT_CMD)

# Build dir adjustments
AM_CONDITIONAL(GNUCASH_SEPARATE_BUILDDIR, test "x${srcdir}" != "x.")

# Init binreloc
AM_BINRELOC

### --------------------------------------------------------------------------
### Glib checks.

# We require glib >= 2.40
# 2.46 deprecates g_settings_list_keys
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.46 gio-2.0 gthread-2.0 gobject-2.0 gmodule-2.0,
      [
        AC_DEFINE([HAVE_GLIB_2_46], [1], [Configure g_settings_list_keys deprecation])
      ],
      [
        PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.40 gio-2.0 gthread-2.0
                                gobject-2.0 gmodule-2.0)
      ])

AC_CHECK_HEADERS(dirent.h dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h)

GLIB_GSETTINGS

GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
AC_SUBST(GLIB_COMPILE_RESOURCES)

# I'm sure we (used to?) require this in various places, so don't remove
# this test unless you've done sufficient code review/testing.
AC_MSG_CHECKING(if unsigned long is at least as big as guint32)
GNC_OLDCFLAGS="$CFLAGS"
GNC_OLDLDFLAGS="$LDFLAGS"
CFLAGS="${CFLAGS} ${GLIB_CFLAGS}"
LDFLAGS="${LDFLAGS} ${GLIB_LIBS}"
AC_TRY_RUN([
  #include <glib.h>
  int main(int argc, char *argv[]) {
    return(!(sizeof(unsigned long) >= sizeof(guint32)));
  }
],[
  AC_MSG_RESULT(yes)
],[
  AC_MSG_RESULT(no)
  AC_MSG_ERROR(cannot continue, size of unsigned long too small.)
],[
  AC_MSG_RESULT(assuming yes)
])
CFLAGS="$GNC_OLDCFLAGS"
LDFLAGS="$GNC_OLDLDFLAGS"

# Gnucash replaced dlopen/dlsym by the g_module functions; dlsym
# is needed optionally in one place for BSD linkers, though.
DL_LIB=
AC_CHECK_FUNCS(dlsym,,[
  AC_CHECK_LIB(dl, dlsym, DL_LIB="-ldl",[
    AC_CHECK_LIB(dld, shl_load, DL_LIB="-ldld",[
      AC_CHECK_FUNCS(dlsym, DL_LIB="")
    ])
  ])
])

oLIBS="$LIBS"
LIBS="$LIBS $DL_LIB"
AC_CHECK_FUNCS(dlerror,,)
LIBS="$oLIBS"
AC_SUBST(DL_LIB)

##################################################
# OS dependent checks
##################################################
AC_SUBST(SED)

# Set some defaults, they may be overridden below
REGEX_LIBS=""
GCC_VERSION=`${CC} -dumpversion`

AC_MSG_CHECKING(operating system)
#NOUNDEF for use with mingw
NOUNDEF=""
case $host_os in
  rhapsody* | darwin[1567].*)
    AC_MSG_RESULT([darwin, but too old])
    AC_MSG_ERROR([This platform is not supported, please
update to latest  darwin])
    ;;
  darwin*)
    platform=darwin
    AC_DEFINE(GNC_PLATFORM_OSX, 1,[Running on OSX, either X11 or Quartz])
    AC_DEFINE(GNC_PLATFORM_POSIX, 1, [POSIX-compliant OS])
    AC_DEFINE(GNC_PLATFORM_DARWIN, 1, [Darwin-based OS])
    AC_MSG_RESULT($platform)
    AC_MSG_CHECKING(For GDK-Quartz)
    platform=osx
    _gdk_tgt=`$PKG_CONFIG --variable=targets gdk-3.0`
    if test "x$_gdk_tgt" = xquartz; then
      platform=darwin/quartz
      AC_DEFINE(GNC_PLATFORM_COCOA, 1, [Cocoa/Nexstep/GnuStep framework])
      AC_MSG_RESULT(yes)
      AC_DEFINE(GDK_QUARTZ,,[Using GDK Quartz (not X11)])
      PKG_CHECK_MODULES([GTK_MAC], gtk-mac-integration-gtk3,
                        [_gtk_mac=yes], [_gtk_mac=no])
      if test "x$_gtk_mac" = xyes; then
        GTK_MAC_LIBS="${GTK_MAC_LIBS} -lobjc -framework Cocoa"
        GTK_MAC_CFLAGS="${GTK_MAC_CFLAGS} -xobjective-c"
        GTK_MAC_CXXFLAGS="${GTK_MAC_CFLAGS} -xobjective-c++"
 	if test "`echo ${GCC_VERSION} | cut -d. -f1`" -eq 4; then
	   if test "`echo ${GCC_VERSION} | cut -d. -f2`" -ge 8; then
      	   # This is gcc >= 4.8.x
	      GTK_MAC_CFLAGS="${GTK_MAC_CFLAGS} -fobjc-exceptions"
	   fi
	fi
     fi
      AC_MSG_RESULT(${_gtk_mac})
      AC_SUBST(GTK_MAC_LIBS)
      AC_SUBST(GTK_MAC_CFLAGS)
      AC_SUBST(GTK_MAC_CXXFLAGS)
    else
      AC_MSG_RESULT(no)
    fi
    ;;
  mingw*|cygwin*)
    platform=win32
    AC_MSG_RESULT($platform)
    AC_DEFINE(GNC_PLATFORM_WINDOWS, 1, [Microsoft Windows OS])
    LT_PROG_RC

    AC_MSG_CHECKING(for native win32)
    case $host_os in
      mingw*)
        native_win32=yes
        AC_MSG_RESULT(yes)

        HTMLHELP_LIBS=
        AC_MSG_CHECKING(for HtmlHelpW)
        saved_LIBS="${LIBS}"
        LIBS="${LIBS} -lhtmlhelp"
        AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <windows.h>
               #include <htmlhelp.h>]],
             [HtmlHelpW(0, (wchar_t*)"", HH_HELP_CONTEXT, 0);])],
          [AC_MSG_RESULT(yes)
           HTMLHELP_LIBS=-lhtmlhelp
           AC_DEFINE(HAVE_HTMLHELPW,1,[System has HtmlHelpW])
          ], [AC_MSG_RESULT(no)])
        LIBS="${saved_LIBS}"
        AC_SUBST(HTMLHELP_LIBS)
        ;;
      *)
        AC_MSG_RESULT(no)
        ;;
    esac

    REGEX_LIBS="-lregex"

    # Adjust CFLAGS and LDFLAGS on Windows
    CFLAGS="${CFLAGS} -mms-bitfields"
#   NOUNDEF will be added to ldflags for the makefiles but not the configures
#   This fixes a problem with libtool and gcc 4.8
    NOUNDEF="-no-undefined"
    LDFLAGS="${LDFLAGS} -mwindows"
    ;;

  *)
    platform=linux/other
    AC_DEFINE(GNC_PLATFORM_POSIX, 1, [POSIX-compliant OS])
    AC_MSG_RESULT($platform)
    ;;
esac
AC_SUBST(REGEX_LIBS)

AM_CONDITIONAL(PLATFORM_LINUX, test "x$platform" = "xlinux/other")
AM_CONDITIONAL(PLATFORM_OSX, test "x$platform" = "xdarwin")
AM_CONDITIONAL(PLATFORM_OSX_QUARTZ, test "x$platform" = "xdarwin/quartz")
AM_CONDITIONAL(PLATFORM_WIN32, test "x$platform" = "xwin32")
AM_CONDITIONAL(OS_WIN32, test "x$native_win32" = "xyes")

# These are unavailable on windows/mingw32
# required for MacOSX Quartz
AC_CHECK_HEADERS(glob.h)

AC_CHECK_FUNCS(chown gethostname getppid getuid gettimeofday gmtime_r)
AC_CHECK_FUNCS(gethostid link)
##################################################



### --------------------------------------------------------------------------
### Guile version checks

GUILE_EFFECTIVE_VERSION=0
# - check minimum version
# - determine GUILE_CFLAGS and GUILE_LIBS

AC_ARG_WITH([guile],
    AS_HELP_STRING([--with-guile=1.8|2.0|auto],
                   [which guile version to compile against @<:@default: auto@:>@]),
    [],
    [with_guile=auto]
)

AS_IF([test "$with_guile" = "2.0"],
      [PKG_CHECK_MODULES(GUILE, [guile-2.0 >= 2.0.0],
                         [GUILE_EFFECTIVE_VERSION=2.0
                          AC_PATH_PROG([GUILD], guild)])],
      [test "$with_guile" = "1.8"],
      [PKG_CHECK_MODULES(GUILE, [guile-1.8 >= 1.8.5],
                         [GUILE_EFFECTIVE_VERSION=1.8])],
      [test "$with_guile" = "auto"],
      [PKG_CHECK_MODULES(GUILE, [guile-2.0 >= 2.0.0],
          [GUILE_EFFECTIVE_VERSION=2.0
           AC_PATH_PROG([GUILD], guild)],
          [PKG_CHECK_MODULES(GUILE, [guile-1.8 >= 1.8.5],
                             [GUILE_EFFECTIVE_VERSION=1.8],
                             [GUILE_EFFECTIVE_VERSION=0])
          ])],
      # else
      [AC_MSG_ERROR([invalid guile version specified])]
)

AS_IF([test "$GUILE_EFFECTIVE_VERSION" = "0"],
      [AC_MSG_ERROR([
       guile does not appear to be installed correctly, or is not in the
       correct version range.  Perhaps you have not installed the guile
       development packages?  Gnucash requires at least version 1.8.5 to build.
       ])]
)

AM_CONDITIONAL(GNC_HAVE_GUILE_2, [test "$GUILE_EFFECTIVE_VERSION" = "2.0"])
AC_SUBST(GUILE_EFFECTIVE_VERSION)
AC_SUBST(GUILE, [`pwd`/gnc-guile])

AC_CHECK_HEADERS(ltdl.h,
         [],
         [AC_MSG_ERROR([ltdl.h not found. Perhaps you need to install
the libtool(-ltdl) development package?])])

### --------------------------------------------------------------------------
### SWIG version checks (only when building from SCM)
#
# In order to build against guile 2 or build the dist we need at least
# version 2.0.10 of SWIG, because that's the first version that supports
# guile 2.
#
# For a guile 1.8 build we accept an older version, but won't allow you
# to build the dist because we need to apply a patch to the swig
# generated files that needs to go into the release tarball. At that
# point we don't know yet which version of guile will be used together
# with that tarball so we have to prepare the tarball for guile 2
# compatibility.
#
if test "${BUILDING_FROM_VCS}" = yes
then
    AX_PKG_SWIG(2.0.10, [gnc_have_swig_2_0_10=yes], [gnc_have_swig_2_0_10=no])

    if test "${GUILE_EFFECTIVE_VERSION}" = "2.0"
    then
        if test "${gnc_have_swig_2_0_10}" = no
        then
            AC_MSG_ERROR([
    You are building from ${VCS_TYPE} but swig was not found or too old.
    To build gnucash you need at least swig version 2.0.10.
            ])
        fi
    else  # using guile 1.8
        if test "${gnc_have_swig_2_0_10}" = no
        then
            AX_PKG_SWIG(1.3.31, [],
                [AC_MSG_ERROR([
    You are building from ${VCS_TYPE} but swig was not found or too old.
    To build gnucash with guile 1.8 you need at least swig version 1.3.31.
            ])])
        fi
    fi

    # If we get here then we have an okay version to build locally.
    # Check if we can build dist (which always requires swig 2.0.10)
    if test "${gnc_have_swig_2_0_10}" = no
    then
        AC_MSG_WARN([You don't have SWIG 2.0.10 so you will not be able to "make dist"])
    fi
    AM_CONDITIONAL([SWIG_DIST_FAIL], test "${gnc_have_swig_2_0_10}" != yes)
else
    # When building from tarball, all the prerequisites to build dist are already
    # met so make sure it's allowed
    AM_CONDITIONAL([SWIG_DIST_FAIL], test yes != yes)
fi

### --------------------------------------------------------------------------
### LIBXML -- GNOME_XML_LIB is defined by GNOME_XML_CHECK

LIBXML2_REQUIRED=2.5.10
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
AC_SUBST(LIBXML2_CFLAGS)
AC_SUBST(LIBXML2_LIBS)

oLIBS="$LIBS"
LIBS="$LIBS $LIBXML2_LIBS"

# Compile a test program to verify that the xml2 library works.
AC_CHECK_LIB(xml2, xmlElemDump, [:], [
  AC_MSG_ERROR([libxml2 is required for GnuCash])
  ])
LIBS="$oLIBS"

### --------------------------------------------------------------------------
### LIBXSLT

PKG_CHECK_MODULES(LIBXSLT, libxslt)
AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_LIBS)

# xsltproc is not included in libxslt on all distributions
# so check for it separately
AC_PATH_PROG(XSLTPROC, xsltproc, [""])

if test -z "$XSLTPROC"; then
  AC_MSG_ERROR([xsltproc is required to build GnuCash])
fi

### --------------------------------------------------------------------------
### Zlib

ZLIB_LIBS=-lz
AC_SUBST(ZLIB_LIBS)

oLIBS="$LIBS"
LIBS="$LIBS $ZLIB_LIBS"
AC_CHECK_LIB(z, gzopen, [:], [
  AC_MSG_ERROR([zlib is required for GnuCash])
])
LIBS="$oLIBS"

### ----------------------
### LIBDBI

AC_ARG_ENABLE(dbi,
  [AS_HELP_STRING([--disable-dbi],[don't build with the libdbi backend])],
  [case "${enableval}" in
     yes) want_dbi=true ;;
     no)  want_dbi=false ;;
     *) want_dbi=false ;;
   esac],
   [want_dbi=true])
if test x${want_dbi} = xtrue
then
  EXTRA_SEARCH_LIBS=""
  AC_CHECK_HEADERS(dbi/dbi.h)
  if test "x$ac_cv_header_dbi_dbi_h" != xno; then
    save_libs=$LIBS
    AC_ARG_WITH( dbi-dbd-dir,
      [AS_HELP_STRING([--with-dbi-dbd-dir=PATH],[specify location of libdbi drivers @<:@default=${libdir}/dbd@:>@])],
      [[GNC_DBD_DIR="$with_dbi_dbd_dir"
       EXTRA_SEARCH_LIBS=$GNC_DBD_DIR]],
      [[GNC_DBD_DIR=""
        # pkg-config is new in libdbi 0.9. Use it if available
        # Otherwise fall back to our previous hard coded values
        pkg-config --exists dbi
        if test $? -eq 0; then
          EXTRA_SEARCH_LIBS="$(pkg-config --variable=libdir dbi)/dbd"
        else
          EXTRA_SEARCH_LIBS="/usr/lib/dbd:/usr/lib64/dbd:${libdir}/dbd:${prefix}/lib/dbd"
        fi]]
       )
    case $host_os in
       win32*|mingw*)
	 LDINC="#include <windows.h>"
	 LDFUNCARGS=""
	 LDEXT=dll
	 ;;
       *)
	 LDINC="#include <dlfcn.h>"
	 LDFUNCARGS=", RTLD_NOW"
	 LDEXT=so
	 export LIBS="$lt_cv_dlopen_libs $LIBS"
	 ;;
      esac
    old_ld_library_path="$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$EXTRA_SEARCH_LIBS"
    AC_MSG_NOTICE([Search Path $LD_LIBRARY_PATH])
    AC_MSG_CHECKING([Looking for at least one supported DBD module])
    AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
				     [[if (!$lt_cv_dlopen("libdbdsqlite3.$LDEXT"$LDFUNCARGS)) return -1;
				     ]])],AC_MSG_RESULT([SQLite3]),
    	AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
				     [[if (!$lt_cv_dlopen("libdbdmysql.$LDEXT"$LDFUNCARGS)) return -1;
					]])],AC_MSG_RESULT([MySql]),
	  AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
				     [[if (!$lt_cv_dlopen("libdbdpgsql.$LDEXT"$LDFUNCARGS)) return -1;
					 ]])],AC_MSG_RESULT([Postgresql]),
        				 AC_MSG_ERROR([
Unable to find any of the supported dbd modules
(libdbdsqlite3, libdbdmysql, or libdbdpgsql) needed to actually use the SQL
backend.

If you do have them installed the problem is either that dlopen cannot
find them or that dlopen itself is not getting linked. Check config.log
to find out which.  You can add the option --with-dbi-dbd-dir pointing to
the directory in which they are located.

If you do not actually want to build with libdi add --disable-dbi
to the configure argument list and run it again.
       ]))))

    LIBDBI_LIBS=-ldbi
    _COMPONENTS="$_COMPONENTS dbi"
    LIBS=$saved_libs
    export LD_LIBRARY_PATH="$old_ld_library_path"
  else
    AC_MSG_ERROR([

 Unable to find <dbi/dbi.h>. Either install the libdbi development
 package (such as libdbi0-dev), or switch off the database backend of
 gnucash by --disable-dbi.
 Note: If you install libdbi, you should also install its database
 drivers (such as libdbd-sqlite3 libdbd-mysql libdbd-pgsql).
])
  fi
fi
AC_SUBST(LIBDBI_LIBS)
AC_SUBST(GNC_DBD_DIR)
AM_CONDITIONAL(CUSTOM_GNC_DBD_DIR, [test x"$GNC_DBD_DIR" != "x"])
AM_CONDITIONAL(WITH_DBI, [test "x$ac_cv_header_dbi_dbi_h" = xyes])

### --------------------------------------------------------------------------
### Variables
### Set up all the initial variable values...
GNC_CONFIGDIR='${sysconfdir}/gnucash'
GNC_DOC_INSTALL_DIR='${docdir}'
GNC_INCLUDE_DIR='${includedir}/gnucash'
GNC_SCM_INSTALL_DIR='${pkgdatadir}/scm'
GNC_SHAREDIR='${pkgdatadir}'
GNC_LIBEXECDIR='${libexecdir}/gnucash'

GNC_ACCOUNTS_DIR='${GNC_SHAREDIR}/accounts'
GNC_CHECKS_DIR='${GNC_SHAREDIR}/checks'
GNC_GTKBUILDER_DIR='${GNC_SHAREDIR}/gtkbuilder'
GNC_UI_DIR='${GNC_SHAREDIR}/ui'
GNC_PIXMAP_DIR='${GNC_SHAREDIR}/pixmaps'

AC_SUBST(GNC_ACCOUNTS_DIR)
AC_SUBST(GNC_CHECKS_DIR)
AC_SUBST(GNC_CONFIGDIR)
AC_SUBST(GNC_DOC_INSTALL_DIR)
AC_SUBST(GNC_GTKBUILDER_DIR)
AC_SUBST(GNC_UI_DIR)
AC_SUBST(GNC_INCLUDE_DIR)
AC_SUBST(GNC_PIXMAP_DIR)
AC_SUBST(GNC_SCM_INSTALL_DIR)
AC_SUBST(GNC_SHAREDIR)
AC_SUBST(GNC_LIBEXECDIR)

AC_ARG_ENABLE( debug,
  [AS_HELP_STRING([--enable-debug],[compile with debugging flags set])],
  [
  if test x$enableval = xyes; then
     # remove any optimization flags...
     CFLAGS=`echo ${CFLAGS} | sed -e 's,-O.,,g'`
     # ...except for those the user wants.
     CFLAGS="${CFLAGS} -g ${USER_OPTIMIZATION}"
     # Do the same for C++
     CXXFLAGS=`echo ${CXXFLAGS} | sed -e 's,-O.,,g'`
     CXXFLAGS="${CXXFLAGS} -g ${USER_OPTIMIZATION}"
     LDFLAGS="${LDFLAGS} -g"
  fi
  ])

AC_ARG_ENABLE( profile,
  [AS_HELP_STRING([--enable-profile],[compile with profiling set])],
  if test x$enableval = xyes; then
      AM_CFLAGS="${AM_CFLAGS} -pg"
      AM_CXXFLAGS="${AM_CXXFLAGS} -pg"
      AM_LDFLAGS="${AM_LDFLAGS} -pg"
  fi)

###---------------------------------------------------------------------------
### Google Profiler Support: https://code.google.com/p/gperftools/
###---------------------------------------------------------------------------
enable_google_profile=no
AC_ARG_ENABLE( google-profiler,
  [AS_HELP_STRING([--enable-google-profiler], [link in Google Performance Tools profiler; allows enabling profiling by setting $CPUPROFILE=/path/to/logfile.])],
  [AC_MSG_CHECKING([Google PerfTools Profiler])
   AC_CHECK_LIB([profiler], [ProfilerEnable], [enable_google_profile=yes],
      [AC_MSG_WARN([Google Profiling Enabled but the library was not found.])])
])
AM_CONDITIONAL(WITH_GOOGLE_PROFILER, [test x$enable_google_profile = xyes])

###---------------------------------------------------------------------------
### Google Test and Mock Support: https://code.google.com/p/googletest/ and
### https://code.google.com/p/googlemock/
### ---------------------------------------------------------------------------
ac_cv_gmock_root=""
ac_cv_gmock_headers=""
ac_cv_gtest_root=""
ac_cv_gtest_headers=""
ac_cv_gtest_libs=""
ac_cv_gmock_libs=""

AC_CHECK_LIB([gtest_main], [main],
    [AC_CHECK_FILES([/usr/src/gmock/gmock-all.cc
                     /usr/include/gtest/gtest.h
                     /usr/include/gmock/gmock.h
                     /usr/src/gmock/src/gmock-all.cc
                     /usr/src/gtest/src/gtest-all.cc],
                    [ac_cv_gtest_system_install=yes] [ac_cv_have_gtest_libs=yes],
                    [ac_cv_gtest_system_install=no])],
    [AC_CHECK_FILES([/usr/src/gtest/src/gtest-all.cc
                     /usr/src/gtest/gtest-main.cc
                     /usr/src/gmock/src/gmock-all.cc
                     /usr/include/gtest/gtest.h
                     /usr/include/gmock/gmock.h],
                    [ac_cv_gtest_system_install=yes] [ac_cv_have_gtest_libs=no],
                    [ac_cv_gtest_system_install=no])]
   )
if test x$ac_cv_file__usr_include_gmock_gmock_h = xyes -a x$ac_cv_file__usr_include_gtest_gtest_h = xyes; then
  if test x$ac_cv_file__usr_src_gmock_src_gmock_all_cc = xyes -a x$ac_cv_file__usr_src_gtest_src_gtest_all_cc = xyes; then
     ac_cv_gtest_system_install=yes
  elif test "x$ac_cv_have_gtest_libs" = xyes; then
     ac_cv_gtest_system_install=yes
  else
     ac_cv_gtest_system_install=no
  fi
fi

AC_ARG_WITH([gtest-root],
    [AS_HELP_STRING([--with-gtest-root=PATH], [location of the google test sources])],
    [ac_cv_gtest_root="$with_gtest_root"])
AC_ARG_WITH([gtest-headers],
    [AS_HELP_STRING([--with-gtest-headers=PATH], [location of the google test header files if not in gtest-root])],
    [ac_cv_gtest_headers="$with_gtest_headers"])
AC_ARG_WITH([gmock-root],
    [AS_HELP_STRING([--with-gmock-root=PATH], [location of the google mock sources])],
    [ac_cv_gmock_root="$with_gmock_root"])
AC_ARG_WITH([gmock-headers],
    [AS_HELP_STRING([--with-gmock-headers=PATH], [location of the google test header files if not in gmock-root])],
    [ac_cv_gmock_headers="$with_gmock_headers"])

google_test_found=yes
AC_MSG_CHECKING([whether Google Test is available])
if test -n "$ac_cv_gtest_root" -a -r "$ac_cv_gtest_root/src/gtest-all.cc"; then
    AC_MSG_WARN([Skipped setting ac_cv_gtest_root, value $ac_cv_gtest_root])
else
   if test -n "${GTEST_ROOT}" -a -r "${GTEST_ROOT}/src/gtest-all.cc"; then
      ac_cv_gtest_root=${GTEST_ROOT}
   elif test "x$ac_cv_gtest_system_install" = "xyes"; then
      ac_cv_gtest_root="/usr/src/gtest"
   else
      ac_cv_gtest_root=""
   fi
fi
if test -z "$ac_cv_gtest_root" -a -z "$ac_cv_gtest_libs"; then
   AC_MSG_RESULT([No gtest-root])
   google_test_found=no
else
   if test ! -r "$ac_cv_gtest_root/include/gtest/gtest.h"; then
      if test -n "$ac_cv_gtest_headers" -a -r "$ac_cv_gtest_headers/gtest/gtest.h"; then
         AC_MSG_WARN([Skipped setting ac_cv_gtest_headers, value $ac_cv_gtest_headers])
      else
         if test  -n "${GTEST_HEADERS}" -a -r "${GTEST_HEADERS}/gtest/gtest.h"; then
            ac_cv_gtest_headers=${GTEST_HEADERS}
         elif test "x$ac_cv_gtest_system_install" = "xyes"; then
            ac_cv_gtest_headers="/usr/include"
         else
            ac_cv_gtest_headers=""
         fi
      fi
      if test -z "$ac_cv_gtest_headers"; then
         AC_MSG_RESULT([No gtest-headers])
         google_test_found=no
      fi
   else
      ac_cv_gtest_headers=$ac_cv_gtest_root/include
   fi
fi


if test -n "$ac_cv_gmock_root" -a -r "$ac_cv_gmock_root/gmock-all.cc"; then
   ac_cv_gmock_src_path="$ac_cv_gmock_root"
   AC_MSG_WARN([Skipped setting ac_cv_gmock_root, value $ac_cv_gmock_root])
elif test -n "$ac_cv_gmock_root" -a -r "$ac_cv_gmock_root/src/gmock-all.cc"; then
   ac_cv_gmock_src_path="$ac_cv_gmock_root/src"
   AC_MSG_WARN([Skipped setting ac_cv_gmock_root, value $ac_cv_gmock_root])
else
   if test -n "${GMOCK_ROOT}" -a -r "${GMOCK_ROOT}/src/gmock-all.cc"; then
       ac_cv_gmock_src_path=${GMOCK_ROOT}/src
       ac_cv_gmock_root=${GMOCK_ROOT}
   elif test "x$ac_cv_gtest_system_install" = "xyes"; then
       if test "x$ac_cv_file__usr_src_gmock_src_gmock_all_cc" = xyes; then
         ac_cv_gmock_src_path="/usr/src/gmock/src"
       elif test "x$ac_cv_file__usr_src_gmock_gmock_all_cc" = xyes; then
          ac_cv_gmock_src_path="/usr/src/gmock"
       else
          ac_cv_gmock_src_path=""
       fi
       ac_cv_gmock_root="/usr/src/gmock"
   else
      ac_cv_gmock_root=""
   fi
fi
if test -z "$ac_cv_gmock_root"; then
   AC_MSG_RESULT([No gmock-root])
   google_test_found=no
else
   if test ! -r "$ac_cv_gmock_root/include/gmock/gmock.h"; then
      if test -n "$ac_cv_gmock_headers" -a -r "$ac_cv_gmock_headers/gmock/gmock.h"; then
         AC_MSG_WARN([Skipped setting ac_cv_gmock_headers, value $ac_cv_gmock_headers])
      else
         if test -n "${GMOCK_HEADERS}" -a -r "${GMOCK_HEADERS}/gmock/gmock.h"; then
            ac_cv_gmock_headers=${GMOCK_HEADERS}
         elif test "x$ac_cv_gtest_system_install" = "xyes"; then
            ac_cv_gmock_headers="/usr/include"
         else
            ac_cv_gmock_headers=""
         fi
      fi
      if test -z "$ac_cv_gmock_headers"; then
         AC_MSG_RESULT([No gmock-headers])
         google_test_found=no
      fi
   else
      ac_cv_gmock_headers="$ac_cv_gmock_root/include"
   fi
fi

if test "x$google_test_found" = "xyes"; then
    AC_MSG_RESULT([Yes])
else
    AC_MSG_ERROR([

 Unable to find the Google test framework. Either install gtest/gmock
 packages or point to the base directories of the sources using
 GTEST_ROOT and GMOCK_ROOT environment variables.
])
fi

if test "x$ac_cv_have_gtest_libs" = xyes; then
   ac_cv_gtest_libs="-lgtest -lgtest_main"
else
dnl Google test requires pthreads and this seems the easiest way to check.
    AX_PTHREAD([
    ac_cv_gtest_libs="\$(top_builddir)/common/test-core/libgtest.a $PTHREAD_CFLAGS"
    ],[
    AC_MSG_ERROR(
      [GTest requires pthreads, but this wasn't found.])
      dnl Google test requires pthreads and this seems the easiest way to check.
    ])
fi

AC_SUBST([GTEST_LIBS], [$ac_cv_gtest_libs])
AC_SUBST([GTEST_SRC], [$ac_cv_gtest_root])
AC_SUBST([GTEST_HEADERS], [$ac_cv_gtest_headers])
AC_SUBST([GMOCK_SRC_PATH], [$ac_cv_gmock_src_path])
AC_SUBST([GMOCK_SRC], [$ac_cv_gmock_root])
AC_SUBST([GMOCK_HEADERS], [$ac_cv_gmock_headers])
AM_CONDITIONAL([GOOGLE_TEST_LIBS], [test "x$ac_cv_have_gtest_libs" = "xyes"])
### --------------------------------------------------------------------------
### Register2
AC_ARG_ENABLE( register2,
  [AS_HELP_STRING([--enable-register2],[compile with register2 enabled])],
  if test x$enableval = xyes; then
    AC_DEFINE(REGISTER2_ENABLED,1,We are using Register2)
  else
    AC_DEFINE(REGISTER2_ENABLED,0,We are not using Register2)
  fi)

### --------------------------------------------------------------------------
### OFX
want_ofx=auto
have_ofx=no
AC_ARG_ENABLE( ofx,
  [AS_HELP_STRING([--enable-ofx],[compile with ofx support (needs LibOFX)])],
  [ case "$enableval" in
    yes) want_ofx=yes ;;
    no)  want_ofx=no ;;
    esac[]dnl
  ] )
AC_MSG_CHECKING(whether to use OFX)
case "${want_ofx}" in
  yes)  AC_MSG_RESULT(yes -- failure is fatal) ;;
  no)   AC_MSG_RESULT(no) ;;
  auto) AC_MSG_RESULT(yes -- automatic test) ;;
esac

if test x${want_ofx} != xno ; then
  PKG_CHECK_MODULES(LIBOFX, libofx, [have_ofx="yes"], [ have_ofx="no" ])
fi

if test x${want_ofx} = xyes && test x${have_ofx} = xno; then
  AC_MSG_ERROR([

 OFX support wanted, but libofx development libraries not found.
 Either install the libofx development package (such as libofx-dev or
 libofx-devel), or drop ofx support. You can do tis by removing
 --enable-dbi from the configure parameters.])
fi

MIGRATABLE_PREFS_OFX="/dev/null"
if test x${have_ofx} = xyes ; then
  _COMPONENTS="$_COMPONENTS ofx"
  MIGRATABLE_PREFS_OFX="$srcdir/gnucash/import-export/ofx/migratable-prefs-ofx.xml"
fi

ofx_has_bug_39=no
if test x${have_ofx} = xyes ; then
  AC_MSG_CHECKING([Does libofx have bug 39])
  libs_old="$LIBS"
  LIBS="$LIBS -lofx"
  AC_LANG_PUSH(C++)
  AC_RUN_IFELSE(
    [AC_LANG_PROGRAM([
#include <time.h>
#include <stdlib.h>
#include <string>
extern time_t ofxdate_to_time_t(const std::string ofxdate);
],[
const std::string timestr = "20160319000000";
struct tm ts;
ts.tm_year = 116;
ts.tm_mon = 2;
ts.tm_mday = 19;
#ifdef _WIN32
putenv(\"TZ=PST-8PDT-7,M 4.1.0/0,M 10.6.0/0\");
#else
setenv("TZ", "PST 08 PDT 07 M 4.1.0, M 10.6.0", 1);
#endif
time_t t = ofxdate_to_time_t(timestr);
if (t == mktime(&ts))
  exit(0);
exit(1);
])],
    [AC_MSG_RESULT(no)], [
    AC_MSG_RESULT(yes)
    ofx_has_bug_39=yes
    ])
  if test x$ofx_has_bug_39 = "xyes"; then
    AC_DEFINE(HAVE_OFX_BUG_39, 1, [Libofx has a daylight-time handling bug.])
  fi
  AC_LANG_POP([C++])
  LIBS="$libs_old"
fi
AM_CONDITIONAL([WITH_OFX], [test "x${have_ofx}" = xyes])
AC_SUBST_FILE([MIGRATABLE_PREFS_OFX])
### --------------------------------------------------------------------------
### MT940
AC_ARG_ENABLE( mt940,
  [AS_HELP_STRING([--enable-mt940],[obsolete, included in --enable-aqbanking])],
  if test "x$enableval" != "xno" ; then
    AC_MSG_ERROR([--enable-mt940 is obsolete -- all functionality is already included in --enable-aqbanking])
  fi)

### --------------------------------------------------------------------------
### AqBanking

AC_ARG_ENABLE( aqbanking,
  [AS_HELP_STRING([--enable-aqbanking],[compile with AqBanking support])],
  if test "x$enableval" != "xno" ; then
    want_aqbanking=yes
  fi)
AC_ARG_ENABLE( hbci,
  [AS_HELP_STRING([--enable-hbci],[obsolete, replaced by --enable-aqbanking])],
  if test "x$enableval" != "xno" ; then
    AC_MSG_ERROR([--enable-hbci is obsolete -- the option has been renamed into --enable-aqbanking])
  fi)

MIGRATABLE_PREFS_AQBANKING="/dev/null"
if test x${want_aqbanking} = xyes ;
then
  # Check for Aqbanking library
  # We require aqbanking-4.0.0 because our implementation doesn't run
  # with earlier version anymore. (libaqbanking ships with a pkgconfig
  # file since its version 1.6.1.)
  PKG_CHECK_MODULES(AQBANKING, aqbanking >= 4.0.0 gwenhywfar, , [
    AC_MSG_ERROR([Could not find aqbanking >= 4.0.0. If you use --enable-aqbanking, you MUST have aqbanking installed!])
  ])
  # For libgwenhywfar > 3.99.20, look for its library gwengui-gtk2.
  PKG_CHECK_MODULES([GWEN], [gwenhywfar], [has_gwen=1], [has_gwen=0])

  # also check for ktoblzcheck
  AC_CHECK_HEADERS(ktoblzcheck.h)
  if test "x$ac_cv_header_ktoblzcheck_h" != xno; then
    AQBANKING_LIBS="${AQBANKING_LIBS} -lktoblzcheck"
  fi

  AC_SUBST(AQBANKING_LIBS)
  AC_SUBST(AQBANKING_CFLAGS)
  _COMPONENTS="$_COMPONENTS aqbanking"
  MIGRATABLE_PREFS_AQBANKING="$srcdir/gnucash/import-export/aqb/migratable-prefs-aqbanking.xml"
fi
AM_CONDITIONAL([WITH_AQBANKING], [test x${want_aqbanking} = xyes])
AC_SUBST_FILE([MIGRATABLE_PREFS_AQBANKING])

AC_ARG_WITH(xdg-data-dirs,
                 [AS_HELP_STRING([--with-xdg-data-dirs],
                 [search path for system XDG data directories [default /usr/local/share/;/usr/share/]])],
                 [GNC_SYSTEM_XDG_DATA_DIRS=$withval],
                 [GNC_SYSTEM_XDG_DATA_DIRS="/usr/local/share;/usr/share"])
AC_SUBST(GNC_SYSTEM_XDG_DATA_DIRS)

AC_ARG_WITH(qt3-wizard-package,
                 [AS_HELP_STRING([--with-qt3-wizard-package=name],[name of package containing qt3-wizard (aqbanking)])],
    [QT3_WIZARD_PACKAGE=$withval], [QT3_WIZARD_PACKAGE=aqbanking])
AC_DEFINE_UNQUOTED([QT3_WIZARD_PACKAGE],["$QT3_WIZARD_PACKAGE"],[Name of package containing qt3-wizard.])

### --------------------------------------------------------------------------
### i18n

# This variable is set by GLIB_WITH_NLS, called through
# AM_GLIB_GNU_GETTEXT above. Usually it is "share", but on some
# platforms it is "lib". Make sure it is set.
if test "x$DATADIRNAME" = "x"; then
  DATADIRNAME="share"
  AC_SUBST(DATADIRNAME)
fi

dnl check for nl_langinfo(D_FMT) which is missing on FreeBSD
LANGINFO_D_FMT_CHECK

dnl Make sure we have a proper gettext installed
AC_MSG_CHECKING(for a valid gettext/gmsgfmt installation)
if test "$gt_cv_have_gettext" != "yes" || test "x$GMSGFMT" = "x"; then
  AC_MSG_RESULT(no)
  AC_MSG_ERROR([Cannot find Glib Gettext.  Maybe you need to install the gettext package?])
else
  AC_MSG_RESULT(yes - $GMSGFMT)
fi

# -------------------------------------------------------------------------
# URLs for MySQL and PostgreSQL testing
AC_ARG_WITH(test-mysql-url,
            AS_HELP_STRING([--with-test-mysql-url=URL],
                           [MySQL database URL for testing [default=none]]),
            [],[with_test_mysql_url=""])

TEST_MYSQL_URL=$with_test_mysql_url
AC_SUBST(TEST_MYSQL_URL)

AC_ARG_WITH(test-pgsql-url,
            AS_HELP_STRING([--with-test-pgsql-url=URL],
                           [PgSQL database URL for testing [default=none]]),
            [],[with_test_pgsql_url=""])

TEST_PGSQL_URL=$with_test_pgsql_url
AC_SUBST(TEST_PGSQL_URL)

### --------------------------------------------------------------------------
### help files

# Used to initialize doc-path.
AC_ARG_WITH( help-prefix,
  [AS_HELP_STRING([--with-help-prefix=PATH],[specify where to store the help files])],
  GNC_HELPDIR="$with_help_prefix",
  GNC_HELPDIR="\${datadir}")
AC_SUBST(GNC_HELPDIR)

### --------------------------------------------------------------------------
### Check for etags

AC_ARG_ENABLE( etags,
  [AS_HELP_STRING([--enable-etags],[enable automatic create of TAGS file])],
  if test x$enableval = xyes; then
     USE_ETAGS=1
  fi,
  USE_ETAGS=0)

if test x${USE_ETAGS} = x1; then
  AC_CHECK_PROG(GNC_ETAGS_FILE, etags, TAGS)
fi

AM_CONDITIONAL(GNC_ETAGS_FILE, test x${GNC_ETAGS_FILE} = xTAGS)

### --------------------------------------------------------------------------
### Check for ctags

AC_ARG_ENABLE( ctags,
  [AS_HELP_STRING([--enable-ctags],[enable automatic create of tags file])],
  if test x$enableval = xyes; then
     USE_CTAGS=1
  fi,
  USE_CTAGS=0)

if test x${USE_CTAGS} = x1; then
  AC_CHECK_PROG(GNC_CTAGS_FILE, ctags, tags)
fi

AM_CONDITIONAL(GNC_CTAGS_FILE, test x${GNC_CTAGS_FILE} = xtags)

### --------------------------------------------------------------------------
### Check for perl

# Check for perl, force version 5
AC_ARG_WITH(perl,
  [AS_HELP_STRING([--with-perl=FILE],[which perl executable to use])],
  PERL="${with_perl}")

# If the user didn't specify a perl, then go fetch.
if test x"$PERL" = x;
then
  AC_PATH_PROG(PERL, perl)
fi

# Make sure Perl was found
if test x"$PERL" = x; then
    AC_MSG_ERROR([Cannot find Perl. Try using the --with-perl flag.])
fi

# Make sure it's version 5 or later
if "$PERL" -e 'exit 1 if $] < 5.0'; then
    :
else
    AC_MSG_ERROR([Found ${PERL} reports version ]
                 [`${PERL} -e 'print $]'`, need version 5.*])
fi
AC_SUBST(PERL)

### ----------------------------------------------------------------------------
### Check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/

AC_DEFUN([BB_ENABLE_DOXYGEN],
  [
    AC_ARG_ENABLE(doxygen, [AS_HELP_STRING([--enable-doxygen],[enable documentation generation with doxygen (auto)])])
    AC_ARG_ENABLE(dot, [AS_HELP_STRING([--enable-dot],[use 'dot' to generate graphs in doxygen (auto)])])
    AC_ARG_ENABLE(html-docs, [AS_HELP_STRING([--enable-html-docs],[enable HTML generation with doxygen (yes)])], [], [ enable_html_docs=yes])
    AC_ARG_ENABLE(latex-docs, [AS_HELP_STRING([--enable-latex-docs],[enable LaTeX documentation generation with doxygen (no)])], [], [ enable_latex_docs=no])
    if test "x$enable_doxygen" = xno; then
      enable_doc=no
    else
      AC_PATH_PROG(DOXYGEN, doxygen, , $PATH)
      if test x$DOXYGEN = x; then
        if test "x$enable_doxygen" = xyes; then
          AC_MSG_ERROR([could not find doxygen])
        fi
        enable_doc=no
      else
        enable_doc=yes
        AC_PATH_PROG(DOT, dot, , $PATH)
      fi
    fi
    AM_CONDITIONAL(DOC, test x$enable_doc = xyes)

    if test x$DOT = x; then
      if test "x$enable_dot" = xyes; then
        AC_MSG_ERROR([could not find dot])
      fi
      enable_dot=no
    else
      enable_dot=yes
    fi
    AM_CONDITIONAL(ENABLE_DOXYGEN, test x$enable_doc = xtrue)
    AC_SUBST(enable_dot)
    AC_SUBST(enable_html_docs)
    AC_SUBST(enable_latex_docs)
  ])

# check for doxygen
BB_ENABLE_DOXYGEN


### --------------------------------------------------------------------------
### Libraries
LIBS="$LIBS -lm"


### --------------------------------------------------------------------------
### Whether or not to build the GTK GUI components.
### When disabled, we don't even need to check for them!
### --------------------------------------------------------------------------

AC_ARG_ENABLE(gui,
  [AS_HELP_STRING([--disable-gui],[build without the GNOME GUI components of Gnucash])],
  [case "${enableval}" in
     yes) gnc_build_gui=true ;;
     no)  gnc_build_gui=false ;;
     *) gnc_build_gui=true ;;
   esac],
   [gnc_build_gui=true])

AM_CONDITIONAL(GNUCASH_ENABLE_GUI, test x${gnc_build_gui} = xtrue)

### --------------------------------------------------------------------------
### GNOME gui components -- built by default, but not if --enable-gui=no
### or --disable-gui is passed to autogen
### --------------------------------------------------------------------------

if test x${gnc_build_gui} = xtrue ;
then
  if test x${enable_compile_warnings} = x ;
  then
    enable_compile_warnings="yes"
  fi
#Save CFLAGS so that we can put the warnings in AM_CFLAGS
  __cflags="$CFLAGS"
  CFLAGS=
  COMPILE_WARNINGS
  AM_CFLAGS="$CFLAGS"
  CFLAGS="$__cflags"

  PKG_CHECK_MODULES(GTK, gtk+-3.0)
  AC_SUBST(GTK_CFLAGS)
  AC_SUBST(GTK_LIBS)

  PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0)
  AC_SUBST(GDK_PIXBUF_CFLAGS)
  AC_SUBST(GDK_PIXBUF_LIBS)

  ### --------------------------------------------------------------------------
  ### checks for webkit

  PKG_CHECK_MODULES(WEBKIT, webkit2gtk-4.0,
  [AC_DEFINE([WEBKIT2_4], [1], [Webkit2Gtk API Version 4.0])],
  [PKG_CHECK_MODULES(WEBKIT, webkit2gtk-3.0,
  [
    case $host_os in
       win32* | mingw*)
          AC_DEFINE([WEBKIT1], [1], [Webkit1Gtk API])
          ;;
       *)
          AC_DEFINE([WEBKIT2_3], [1], [Webkit2Gtk API Version 3.0])
          ;;
     esac
   ],)])

    ###-----------------------------------------------------------------------
  ## Find a suitable password store
  AC_ARG_ENABLE([password-storage],
                AS_HELP_STRING([--disable-password-storage], [Ignore system wide password stores such as gnome-keyring, libsecret or Apple's keychain]))

  have_password_storage=no
  if test "x$enable_password_storage" != "xno"
  then
    case $host_os in
    darwin*)
      have_password_storage=yes
      AC_DEFINE(HAVE_OSX_KEYCHAIN,1,[System has an OS X Key chain])
      ;;
    *)
      PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1 >= "0.6",
          [have_password_storage=yes
           AC_DEFINE(HAVE_GNOME_KEYRING,1,[System has gnome-keyring 0.6 or better])
          ],
          [dummy_not_found=true])

      PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= "0.18",
          [have_password_storage=yes
           AC_DEFINE(HAVE_LIBSECRET,1,[System has libsecret 0.18 or better])
           AC_SUBST(LIBSECRET_CFLAGS)
           AC_SUBST(LIBSECRET_LIBS)
          ],
          [dummy_not_found=true])
      ;;
    esac
  fi

  if test "x$have_password_storage" = "xno" && test "x$enable_password_storage" = "xyes"
  then
      AC_MSG_ERROR([password storage requested but no suitable backend found. Either gnome-keyring >= 0.6, libsecret >= 0.18 or Apple's keychain are supported])
  fi


  ### ----------------------------------------------------------------------

  AC_ARG_ENABLE( efence,
    [AS_HELP_STRING([--enable-efence],[link using efence])],
    if test x$enableval = xyes; then
      EFENCE_LIBS="-lefence"
      USE_EFENCE=1
      AC_DEFINE(USE_EFENCE,,We are using EFence)
    fi,
    USE_EFENCE=0
    EFENCE_LIBS="")
  AC_SUBST(EFENCE_LIBS)

  ### ----------------------------------------------------------------------
  ## For now, we just presume you're using the GNOME version.  The other
  ## UI's haven't been carried over during the automake transition.  At
  ## some point, if it's deemed worthwhile, they can be resurrected...

  GNOME=1
  AC_DEFINE(GNOME,,using GNOME)
  AM_CXXFLAGS="${AM_CXXFLAGS} -Wall"

else
  # COMPILE_WARNINGS will add -Wall; no need to set it again.
  # also, only add it for GCC.
  if test ${GCC}x = yesx
  then
    # We should always see these errors...
    AM_CFLAGS="${AM_CFLAGS} -Wall"
    AM_CXXFLAGS="${AM_CXXFLAGS} -Wall"
  fi

fi
### End of gui-only checks

###-------------------------------------------------------------------------
### Selectively disable deprecated bits of glib/gdk/gtk/gnome
###-------------------------------------------------------------------------

allow_deprecated=true
AC_ARG_ENABLE(deprecated-glib,
  [AS_HELP_STRING([--disable-deprecated-glib],[don't use deprecated glib functions])],
  [case "${enableval}" in
     no) allow_deprecated=false ;;
     *)  allow_deprecated=true ;;
   esac]
  )
if test x${allow_deprecated} != "xtrue"
then
  # FIXME: This define is unused; this block can be removed
  AC_DEFINE(G_DISABLE_DEPRECATED,1, [Don't use deprecated glib functions])
fi


# default: Allow deprecated gtk functions
allow_deprecated=true
AC_ARG_ENABLE(deprecated-gtk,
  [AS_HELP_STRING([--disable-deprecated-gtk],[don't use deprecated gtk, gdk or gdk-pixbuf functions])],
  [case "${enableval}" in
     no) allow_deprecated=false ;;
     *)  allow_deprecated=true ;;
   esac]
  )
if test x${allow_deprecated} != "xtrue"
then
  # FIXME: This define is unused; this block can be removed
  AC_DEFINE(GTK_DISABLE_DEPRECATED,1, [Don't use deprecated gtk functions])
  AC_DEFINE(GDK_DISABLE_DEPRECATED,1, [Don't use deprecated gdk functions])
  AC_DEFINE(GDK_PIXBUF_DISABLE_DEPRECATED,1, [Don't use deprecated gdk-pixbuf functions])
fi


allow_deprecated=true
AC_ARG_ENABLE(deprecated-gnome,
  [AS_HELP_STRING([--disable-deprecated-gnome],[don't use deprecated gnome functions])],
  [case "${enableval}" in
     no) allow_deprecated=false ;;
     *)  allow_deprecated=true ;;
   esac]
  )
if test x${allow_deprecated} != "xtrue"
then
  # FIXME: This define is unused; this block can be removed
  AC_DEFINE(GNOME_DISABLE_DEPRECATED,1, [Don't use deprecated gnome functions])
fi

AC_CHECK_FUNCS(pthread_mutex_init)
AC_REPLACE_FUNCS(strptime strfmon)

if test x$am_cv_val_LC_MESSAGES = "xno"; then
  LC_MESSAGES_ENUM="LC_ALL"
else
  LC_MESSAGES_ENUM="LC_MESSAGES"
fi
AC_SUBST(LC_MESSAGES_ENUM)

###--------------------------------------------------------
### Make Python plugin and bindings optional
###--------------------------------------------------------

AC_ARG_ENABLE(python,
  [AS_HELP_STRING([--enable-python],[enable python plugin and bindings])],
  [case "${enableval}" in
     yes) enable_python=true ;;
     no) enable_python=false ;;
     *) enable_python=false    # default: false
   esac],
  [enable_python=false] # default: false
  )
if test x${enable_python} = "xtrue"
then
  # Check for Python. We require python-2.4

  AM_PATH_PYTHON(2.4,,[
	   AC_MSG_ERROR([Could not find python >= 2.4. If you use --enable-python, you MUST have python installed!])
    ])
  AC_PYTHON_DEVEL(>= '2.4')
  if test "x${PYTHON}" = "x"
  then
	   AC_MSG_ERROR([Could not find Python development files. Make sure that the correct python-devel package is installed.])
  fi
  SWIG_PYTHON
  _COMPONENTS="$_COMPONENTS python"
fi
AM_CONDITIONAL(WITH_PYTHON, [test x${enable_python} = xtrue])

AC_ARG_ENABLE(python-bindings,
  [AS_HELP_STRING([--enable-python-bindings],[obsolete: replaced by --enable-python])],
  if test "x$enableval" != "xno" ; then
    AC_MSG_ERROR([--enable-python-bindings is obsolete: The option has been renamed into --enable-python])
  fi)


###-------------------------------------------------------------------------
### Additional compiler warnings (or not) if we're running GCC
###-------------------------------------------------------------------------


# This has to come after AC_PROG_CC _AND_ COMPILE_WARNINGS
AC_LANG([C++])
AX_CHECK_COMPILE_FLAG([-Wno-deprecated-register],
    [AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-unused -Wno-deprecated-register"],
    [AM_CXXFLAGS="${AM_CXXFLAGS} -Wno-unused"], [-Werror])
AC_LANG([C])

AC_MSG_CHECKING(what extra warning flags to pass to the C compiler)
if test ${GCC}x = yesx
then
  warnFLAGS=
  warnXXFLAGS=
  #We have a lot of unused variables. Don't warn until someone gets
  #around to cleaning them up.
  AM_CFLAGS="${AM_CFLAGS} -Wno-unused -Wno-deprecated-declarations"
  # other flags...
  # These next two are included in the COMPILE_WARNINGS
  #warnFLAGS="${warnFLAGS} -Wmissing-prototypes"
  #warnFLAGS="${warnFLAGS} -Wmissing-declarations"
  #warnFLAGS="${warnFLAGS} -Werror-implicit-function-declaration" # In -Wall

  # error-on-warning should not be active in (stable) release tarballs
  if test "x$BUILDING_FROM_VCS" = "xyes"
  then
    # This code is from svn/svk/git/bzr, so enable error-on-warning
    error_on_warning_as_default="yes"
  else
    # This is from a tarball, so disable error-on-warning
    error_on_warning_as_default="no"
  fi

  # Enable error-on-warning by default -- I'm tired of fixing other
  # people's missing #includes, etc.
  AC_ARG_ENABLE(error-on-warning,
    [AS_HELP_STRING([--disable-error-on-warning],[disable treating compile warnings as errors])],
    [case "${enableval}" in
       yes) warnFLAGS="${warnFLAGS} -Werror" ; warnXXFLAGS="${warnXXFLAGS} -Werror" ; gnc_error_on_warning=yes ;;
       no)  gnc_error_on_warning=no ;;
       *) AC_MSG_ERROR(bad value ${enableval} for --enable-error-on-warning) ;;
     esac],
    [ if test "${error_on_warning_as_default}" = "yes"; then
        warnFLAGS="${warnFLAGS} -Werror";
        warnXXFLAGS="${warnXXFLAGS} -Werror";
        gnc_error_on_warning=auto
      else
        gnc_error_on_warning=no
      fi
    ])

  warnFLAGS="${warnFLAGS} -Wdeclaration-after-statement -Wno-pointer-sign"
  # rpmbuild on FC4 forces this flag. Can't hurt to always compile with it.
  cflags_save="$CFLAGS"
  CFLAGS="$AM_CFLAGS $CFLAGS -Werror -D_FORTIFY_SOURCE=2"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
	 ]],
	 [[ printf( "%s\n", "Hello World!");]])],
	 [warnFLAGS="${warnFLAGS} -D_FORTIFY_SOURCE=2"])
  CFLAGS="$cflags_save"

  AM_CFLAGS="${warnFLAGS} ${AM_CFLAGS}"
  AM_CXXFLAGS="${warnXXFLAGS} ${AM_CXXFLAGS}"
else
  warnFLAGS=none
fi
# Workaround for bug in gtest on mingw, see
# https://github.com/google/googletest/issues/893
# https://github.com/google/googletest/issues/920
case $host_os in
    mingw*)
      AM_CXXFLAGS="${AM_CXXFLAGS} -DWINVER=0x0500 -D_EMULATE_GLIBC=0"
esac
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CXXFLAGS)
AC_MSG_RESULT($warnFLAGS)

### --------------------------------------------------------------------------
### Adjustments -- especially executables that aren't generated via
### makefiles, so that we don't have an opportunity to adjust them
### there.

chmod u+x ${srcdir}/gnucash/generate-gnc-script

### --------------------------------------------------------------------------
### Makefile creation

# This is necessary so that .o files in LIBOBJS are also built via
# the ANSI2KNR-filtering rules.
LIBOBJS_SEDSCRIPT="s,\.[[^.]]* ,$U&,g;s,\.[[^.]]*\$\$,$U&,"
AC_SUBST(LIBOBJS_SEDSCRIPT)
# Don't add empty lines in the following macro, they
# will cause the Windows build to fail if using a git repo as source
AC_CONFIG_FILES(
  po/Makefile.in
  dnl # Makefiles
  Makefile
  data/Makefile
  data/accounts/Makefile
  data/accounts/C/Makefile
  data/accounts/ca/Makefile
  data/accounts/cs/Makefile
  data/accounts/da/Makefile
  data/accounts/de_AT/Makefile
  data/accounts/de_CH/Makefile
  data/accounts/de_DE/Makefile
  data/accounts/el_GR/Makefile
  data/accounts/en_GB/Makefile
  data/accounts/es_ES/Makefile
  data/accounts/es_MX/Makefile
  data/accounts/fi_FI/Makefile
  data/accounts/fr_CA/Makefile
  data/accounts/fr_CH/Makefile
  data/accounts/fr_FR/Makefile
  data/accounts/hu_HU/Makefile
  data/accounts/it/Makefile
  data/accounts/ja/Makefile
  data/accounts/ko/Makefile
  data/accounts/lt/Makefile
  data/accounts/lv/Makefile
  data/accounts/nb/Makefile
  data/accounts/nl/Makefile
  data/accounts/pl/Makefile
  data/accounts/pt_BR/Makefile
  data/accounts/pt_PT/Makefile
  data/accounts/ru/Makefile
  data/accounts/sk/Makefile
  data/accounts/sv_AX/Makefile
  data/accounts/sv_FI/Makefile
  data/accounts/sv_SE/Makefile
  data/accounts/tr_TR/Makefile
  data/accounts/zh_CN/Makefile
  data/accounts/zh_HK/Makefile
  data/accounts/zh_TW/Makefile
  data/checks/Makefile
  data/pixmaps/Makefile
  bindings/Makefile
  bindings/python/Makefile
  bindings/python/tests/Makefile
  borrowed/Makefile
  borrowed/goffice/Makefile
  borrowed/libc/Makefile
  borrowed/gwengui-gtk3/Makefile
  common/Makefile
  common/debug/Makefile
  common/debug/valgrind/Makefile
  common/test-core/Makefile
  doc/Makefile
  doc/examples/Makefile
  gnucash/Makefile
  gnucash/gnome/Makefile
  gnucash/gnome/gtkbuilder/Makefile
  gnucash/gnome/gschemas/Makefile
  gnucash/gnome/ui/Makefile
  gnucash/gnome-utils/Makefile
  gnucash/gnome-utils/gtkbuilder/Makefile
  gnucash/gnome-utils/gschemas/Makefile
  gnucash/gnome-utils/test/Makefile
  gnucash/gnome-utils/ui/Makefile
  gnucash/gnome-search/Makefile
  gnucash/html/Makefile
  gnucash/import-export/Makefile
  gnucash/import-export/test/Makefile
  gnucash/import-export/ofx/gschemas/Makefile
  gnucash/import-export/qif-imp/Makefile
  gnucash/import-export/qif/Makefile
  gnucash/import-export/qif/test/Makefile
  gnucash/import-export/qif-imp/gschemas/Makefile
  gnucash/import-export/qif-imp/test/Makefile
  gnucash/import-export/gschemas/Makefile
  gnucash/import-export/ofx/Makefile
  gnucash/import-export/ofx/test/Makefile
  gnucash/import-export/csv-imp/Makefile
  gnucash/import-export/csv-imp/gschemas/Makefile
  gnucash/import-export/csv-imp/test/Makefile
  gnucash/import-export/csv-exp/Makefile
  gnucash/import-export/csv-exp/gschemas/Makefile
  gnucash/import-export/log-replay/Makefile
  gnucash/import-export/aqb/Makefile
  gnucash/import-export/aqb/gschemas/Makefile
  gnucash/import-export/aqb/test/Makefile
  gnucash/import-export/bi-import/Makefile
  gnucash/import-export/bi-import/gtkbuilder/Makefile
  gnucash/import-export/bi-import/ui/Makefile
  gnucash/import-export/customer-import/Makefile
  gnucash/import-export/customer-import/gtkbuilder/Makefile
  gnucash/import-export/customer-import/ui/Makefile
  gnucash/python/Makefile
  gnucash/python/pycons/Makefile
  gnucash/register/Makefile
  gnucash/register/ledger-core/Makefile
  gnucash/register/ledger-core/test/Makefile
  gnucash/register/register-core/Makefile
  gnucash/register/register-core/test/Makefile
  gnucash/register/register-gnome/Makefile
  gnucash/register/register-gnome/test/Makefile
  gnucash/report/Makefile
  gnucash/report/report-gnome/Makefile
  gnucash/report/report-gnome/test/Makefile
  gnucash/report/report-system/Makefile
  gnucash/report/report-system/test/Makefile
  gnucash/report/standard-reports/Makefile
  gnucash/report/standard-reports/test/Makefile
  gnucash/report/business-reports/Makefile
  gnucash/report/locale-specific/Makefile
  gnucash/report/locale-specific/us/Makefile
  gnucash/report/locale-specific/us/test/Makefile
  gnucash/report/stylesheets/Makefile
  gnucash/report/stylesheets/test/Makefile
  gnucash/report/utility-reports/Makefile
  gnucash/report/jqplot/Makefile
  libgnucash/Makefile
  libgnucash/app-utils/Makefile
  libgnucash/app-utils/test/Makefile
  libgnucash/backend/Makefile
  libgnucash/backend/dbi/Makefile
  libgnucash/backend/dbi/test/Makefile
  libgnucash/backend/xml/Makefile
  libgnucash/backend/xml/test/Makefile
  libgnucash/backend/xml/test/test-files/Makefile
  libgnucash/backend/xml/test/test-files/xml2/Makefile
  libgnucash/backend/sql/Makefile
  libgnucash/backend/sql/test/Makefile
  libgnucash/core-utils/Makefile
  libgnucash/core-utils/test/Makefile
  libgnucash/doc/Makefile
  libgnucash/doc/design/Makefile
  libgnucash/doc/xml/Makefile
  libgnucash/engine/Makefile
  libgnucash/engine/test/Makefile
  libgnucash/engine/test-core/Makefile
  libgnucash/gnc-module/Makefile
  libgnucash/gnc-module/test/Makefile
  libgnucash/gnc-module/test/mod-foo/Makefile
  libgnucash/gnc-module/test/mod-bar/Makefile
  libgnucash/gnc-module/test/mod-baz/Makefile
  libgnucash/gnc-module/test/misc-mods/Makefile
  libgnucash/quotes/Makefile
  libgnucash/scm/Makefile
  libgnucash/scm/gnumeric/Makefile
  libgnucash/tax/Makefile
  libgnucash/tax/us/Makefile
  libgnucash/tax/us/test/Makefile
  dnl # non-makefiles
  gnucash/gnucash.rc
  libgnucash/app-utils/migratable-prefs.xml
  gnucash/gnome/gnucash.desktop.in
  dnl # GSettings schema files
  gnucash/gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.checkprinting.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.commodities.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.reconcile.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.sxs.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.dialogs.totd.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
  gnucash/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in
  gnucash/gnome-utils/gschemas/org.gnucash.history.gschema.xml.in
  gnucash/gnome-utils/gschemas/org.gnucash.warnings.gschema.xml.in
  gnucash/import-export/aqb/gschemas/org.gnucash.dialogs.import.hbci.gschema.xml.in
  gnucash/import-export/csv-exp/gschemas/org.gnucash.dialogs.export.csv.gschema.xml.in
  gnucash/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in
  gnucash/import-export/gschemas/org.gnucash.dialogs.import.generic.gschema.xml.in
  gnucash/import-export/ofx/gschemas/org.gnucash.dialogs.import.ofx.gschema.xml.in
  gnucash/import-export/qif-imp/gschemas/org.gnucash.dialogs.import.qif.gschema.xml.in
  dnl # Please read doc/build-system before adding *anything* here
  ,
  dnl # init-commands go here
)
dnl # Shell scripts, to have their shells set
AC_CONFIG_FILES([libgnucash/backend/xml/test/test-real-data.sh],
                [chmod +x libgnucash/backend/xml/test/test-real-data.sh])


#Link (copy on Windows) test data files:
AC_CONFIG_LINKS([gnucash/import-export/csv-imp/test/sample1.csv:gnucash/import-export/csv-imp/test/sample1.csv])
LDFLAGS="${LDFLAGS} ${NOUNDEF}"
AC_OUTPUT


AC_MSG_RESULT([
  Options detected/selected
  -------------------------
  gnucash version ...... : $VERSION
  Build for host ....... : $host
  Optional components... : $_COMPONENTS
  Extra Warnings ....... : $warnFLAGS
  CPPFLAGS ............. : $CPPFLAGS
  CFLAGS ............... : $CFLAGS
  CXXFLAGS ............. : $CXXFLAGS
  LDFLAGS .............. : $LDFLAGS
  prefix................ : ${prefix}


])
